#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> v(n + 2, vector<int>(n + 2, 0));
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            cin >> v[i][j];
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (v[i][j] == 0) continue;
            if (v[i][j] > 0 && (v[i][j] <= v[i - 1][j] || v[i][j] <= v[i + 1][j] || v[i][j] <= v[i][j - 1] || v[i][j] <= v[i][j + 1]))
            {
                cout << "NO";
                return;
            }
            else if (v[i][j] < 0 && (v[i][j] >= v[i - 1][j] || v[i][j] >= v[i + 1][j] || v[i][j] >= v[i][j - 1] || v[i][j] >= v[i][j + 1]))
            {
                cout << "NO";
                return;
            }
        }
    }
    cout << "YES";
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}